package insight.Builder;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author huu
 * @create 2025-08-26-18:54
 */
public class InsertBulider {
    //insert 语句 ： insert into 表名 (字段1,字段2,字段3) values (值1,值2,值3)
    private String table;
    private Map<String, String> insertColumns = new LinkedHashMap<>();
    public void InsertBuilder(){
    }
    public InsertBulider table(String table){
        this.table = table;
        return this;
    }
    public InsertBulider insert(String column, String value){
        insertColumns.put(column, value);
        return this;
    }
    public String build(){
        StringBuilder sql = new StringBuilder();
        sql.append("insert into ").append(table).append("(");
        for (String column : insertColumns.keySet()) {
            sql.append(column).append(",");
        }
        sql.deleteCharAt(sql.length() - 1);
        sql.append(") values (");
        for (String value : insertColumns.values()) {
            sql.append(value).append(",");
        }
        sql.deleteCharAt(sql.length() - 1);
        sql.append(")");
        return sql.toString();
    }

}
